Skip to content

fix(workers): make hardcoded run-workers overall timeout configurable#5545

Open
gololdf1sh wants to merge 2 commits intocodeceptjs:4.xfrom
gololdf1sh:fix/configurable-workers-timeout
Open

fix(workers): make hardcoded run-workers overall timeout configurable#5545
gololdf1sh wants to merge 2 commits intocodeceptjs:4.xfrom
gololdf1sh:fix/configurable-workers-timeout

Conversation

@gololdf1sh
Copy link
Copy Markdown

@gololdf1sh gololdf1sh commented Apr 30, 2026

Problem

run-workers has a hardcoded 10-min overall timeout (added in #5370). When it fires, all still-running workers are force-terminated and their results never reach the aggregated summary — silently dropped. No CLI/env/config override exists.

Hit this on a 4-worker run of a ~50-min sequential suite: only 28% of tests reported, with [Main] Overall timeout reached (10 minutes) at t=10m07s.

Fix

Make the timeout configurable. Default 600000 ms preserved (backward-compat). Resolution order:

  1. CODECEPT_WORKERS_TIMEOUT env var (ms)
  2. workersTimeout in codecept.conf (ms)
  3. Default 600000

0 disables the timeout entirely. Log message minutes value is now dynamic.

Changes

  • lib/workers.js: extract _getWorkersTimeoutMs(), gate setTimeout behind > 0 check
  • typings/index.d.ts: add workersTimeout?: number to MainConfig
  • test/unit/worker_test.js: 6 unit tests (default / env / config / precedence / disabled / non-numeric fallback) — all pass

Type of change

  • 🐛 Bug fix
  • 🚀 New functionality

The `run-workers` command has had a hardcoded 10-minute overall timeout
since codeceptjs#5370 ("fix workers crash"). When the timeout fires, ALL still-running
workers are force-terminated and only results from naturally-finished workers
make it into the aggregated summary.

For suites whose total wall-clock with N workers is in the same ballpark
as 10 minutes, this guarantees a portion of tests will be silently dropped
from the report — even on a healthy run. There is currently no CLI flag,
env var, or config option to override.

Make the timeout configurable, with `600000` ms (10 min) preserved as
default for backward compatibility:

1. `CODECEPT_WORKERS_TIMEOUT` env var (ms) — highest precedence
2. `workersTimeout` field in codecept.conf (ms)
3. Default `600000`

Setting the value to `0` (or any non-positive number) disables the
timeout entirely.

Adds 6 unit tests covering resolution order, env-over-config precedence,
disabled mode, and non-numeric fallback.
Copy link
Copy Markdown
Contributor

@DavertMik DavertMik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move default timeout to const

Comment thread lib/workers.js Outdated
if (Number.isFinite(envTimeout)) return envTimeout
const configTimeout = this.codecept?.config?.workersTimeout
if (Number.isFinite(configTimeout)) return configTimeout
return 600000
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

600 000 = 10x60x100

Add const

const WORKER_TIMEOUT_MINUTES =10
Suggested change
return 600000
return WORKER_TIMEOUT_MINUTES*60*1000

Address review feedback on codeceptjs#5545: replace the magic literal `600000` in
`_getWorkersTimeoutMs()` with a module-level `WORKER_TIMEOUT_MINUTES`
constant and an explicit `* 60 * 1000` conversion, so the default value
reads as "10 minutes" at the call site.

No behavior change — default still resolves to 600000 ms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants